﻿using System.Collections.Generic;
using System.ComponentModel;
using System.Windows.Data;
using Contracts.Entities;
using System.Linq;
using System.Windows.Input;

namespace Client.ViewModels
{
    public class MovieListViewModel : WorkspaceViewModel
    {
        private IEnumerable<MovieItem> selectedItems;

        public MovieListViewModel()
        {
            IsListView = true;
            Items = CollectionViewSource.GetDefaultView(new List<MovieItem>());
        }

        public ICollectionView Items
        {
            get;
            set;
        }


        public override IEnumerable<MovieItem> MovieItems
        {
            get
            {                         
                return Items.SourceCollection as IEnumerable<MovieItem>;
            }
            set
            {
                Items = CollectionViewSource.GetDefaultView(value);
                NotifyPropertyChanged("Items");
            }
        }

        /// <summary>
        /// Aktueller Eintrag
        /// </summary>
        public override MovieItem MovieItem
        {
            get
            {
                if (MovieItems == null)
                    return null;

                return Items.CurrentItem as MovieItem;
            }
            set 
            {
 
            }
        }

        public override IEnumerable<MovieItem> SelectedItems
        {
            get
            {
                return selectedItems;
            }
            set
            {
                selectedItems = value;
                NotifyPropertyChanged("SelectedItems");
            }
        }
    }
}
